package org.robotfish.utils;

import static org.junit.Assert.*;

import java.io.IOException;
import java.text.ParseException;

import org.ejml.simple.SimpleMatrix;
import org.junit.Test;

public class TableIOTest {
	@Test 
	public void testCountDims() throws IOException {
		int[] dims = TableIO.countDimensions("data/FishRobot21Proov.crd", TableIO.splitSpaces);
		assertArrayEquals(dims, new int[]{22, 4});
	}
	
	@Test
	public void testReadTable() throws IOException, ParseException {
		SimpleMatrix m = TableIO.readTable("data/FishRobot21Proov.crd");
		//m.print();
		assertEquals(22, m.numRows() );
		assertEquals( 4, m.numCols() );
		assertEquals(1.3877787807814461e-015, m.get(10, 3), 1e-8);
		assertEquals(1.5308165, m.get(11, 2), 1e-8);
		assertEquals(7.4192150e-001, m.get(21,1), 1e-8);
	}
}
